package myzd.api.code;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liuqian
 */
public class CodeUtils {

  private static Map<String, String> codeMessageMap = new HashMap<>();
  public static String SUCCESS_NO = "1000000";
  public static String ERROR_SERVICE_CONNECT = "2410001";
  public static String ERROR_WRONG_PARAMETERS = "2410002";
  public static String ERROR_HOSPITAL_NOT_FOUND = "2410003";
  public static String ERROR_DISEASE_NOT_FOUND = "2410004";
  public static String ERROR_CITY_NOT_FOUND = "2410005";
  public static String ERROR_PROVINCE_NOT_FOUND = "2410006";
  public static String ERROR_DOCTOR_NOT_FOUND = "2410007";
  public static String ERROR_QIYE_USER_NOT_FOUND = "2410008";
  public static String ERROR_QIYE_GET_TOKEN = "2410009";
  public static String ERROR_USER_NOT_FOUND = "2410010";
  public static String ERROR_DATE = "2410011";
  public static String ERROR_ID_CARD = "2410012";
  public static String ERROR_ACCOUNT_NAME = "2410013";
  public static String ERROR_ACCOUNT_INFO = "2410014";
  public static String ERROR_PATIENT_AGE = "2410015";
  public static String ERROR_JWT_TOKEN = "2498002";
  public static String ERROR_GET_FILE_TOKEN = "3111066";
  public static String  ERROR_HEADER_CODE= "319900";


  static {
    codeMessageMap.put(SUCCESS_NO, "成功");
    codeMessageMap.put(ERROR_SERVICE_CONNECT, "网络繁忙，稍后再试");
    codeMessageMap.put(ERROR_WRONG_PARAMETERS, "参数错误");
    codeMessageMap.put(ERROR_HOSPITAL_NOT_FOUND, "医院不存在");
    codeMessageMap.put(ERROR_DISEASE_NOT_FOUND, "疾病不存在");
    codeMessageMap.put(ERROR_CITY_NOT_FOUND, "城市不存在");
    codeMessageMap.put(ERROR_PROVINCE_NOT_FOUND, "省份不存在");
    codeMessageMap.put(ERROR_DOCTOR_NOT_FOUND, "医生不存在");
    codeMessageMap.put(ERROR_QIYE_USER_NOT_FOUND, "受理人不存在");
    codeMessageMap.put(ERROR_QIYE_GET_TOKEN, "获取企业微信TOKEN失败");
    codeMessageMap.put(ERROR_USER_NOT_FOUND, "用户不存在");
    codeMessageMap.put(ERROR_DATE, "时间格式错误");
    codeMessageMap.put(ERROR_JWT_TOKEN, "加密jwtToken错误");
    codeMessageMap.put(ERROR_ID_CARD, "身份证格式错误");
    codeMessageMap.put(ERROR_ACCOUNT_NAME, "医生收款账户姓名错误");
    codeMessageMap.put(ERROR_ACCOUNT_INFO, "医生收款账户信息错误");
    codeMessageMap.put(ERROR_PATIENT_AGE, "患者年龄错误");
    codeMessageMap.put(ERROR_GET_FILE_TOKEN, "得到文件token错误");
    codeMessageMap.put(ERROR_HEADER_CODE, "Token 没有提供");
  }

  public static String getErrText(String code) {
    if (StringUtils.isNoneBlank(codeMessageMap.get(code))) {
      return codeMessageMap.get(code);
    } else {
      return "Unknown-error";
    }
  }
}
